package com.apexedu.biz.service.impl;

import com.apexedu.biz.action.AnnotationExampleAction;
import com.apexedu.framework.service.impl.AbstractBaseServiceSupport;
import com.apexedu.framework.util.Pager;
import com.apexedu.identity.entity.TSysUser;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 使用注解的service示例
 * @Transactional 注解是让类支持事务。需要事务控制的类才需要此注解！！
 * 默认事务是readOnly=false的，所以list等方法上最好再加上@Transactional(readOnly = true)。
 * 另外默认的事务回滚，是运行时异常才回滚；一般的checked Exception不回滚的！！具体可以参见spring手册。
 * @author Yangjianliang
 * datetime 2012-6-13
 */
@Service("annotationExampleService")
@Transactional
public class AnnotationExampleServiceImpl extends AbstractBaseServiceSupport {

	private static final Log LOG = LogFactory.getLog(AnnotationExampleServiceImpl.class);

	/* (non-Javadoc)
	 * @see com.apexedu.framework.service.BaseService#list(java.lang.Object, com.apexedu.framework.util.Pager)
	 */
	@Override
	@Transactional(readOnly = true)
	public List<?> list(Object arg0, Pager arg1) throws Exception {
		// TODO Auto-generated method stub
		LOG.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
		AnnotationExampleAction action = (AnnotationExampleAction)arg0;
		TSysUser user = action.getTsysUser();
		baseDao.save(user);
		return null;
	}

	/* (non-Javadoc)
	 * @see com.apexedu.framework.service.BaseService#load(java.lang.Object)
	 */
	@Override
	@Transactional(readOnly = true)
	public void load(Object arg0) throws Exception {
		// TODO Auto-generated method stub
		
	}

	/* (non-Javadoc)
	 * @see com.apexedu.framework.service.BaseService#remove(java.lang.Object)
	 */
	@Override
	public boolean remove(Object arg0) throws Exception {
		// TODO Auto-generated method stub
		return false;
	}

	/* (non-Javadoc)
	 * @see com.apexedu.framework.service.BaseService#saveOrUpdate(java.lang.Object)
	 */
	@Override
	public void saveOrUpdate(Object arg0) throws Exception {
		// TODO Auto-generated method stub
		
	}
    //controller shi action bao lijie ?

}

